<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Align Content Example</title>
  <style>
    /* Flex 容器样式 */
    .container {
      display: flex;
      flex-wrap: wrap; /* 允许项目换行 */
      height: 400px; /* 限制容器高度，便于观察效果 */
      border: 2px solid #333;
      gap: 10px; /* 项目间距 */
    }

    /* Flex 项目样式 */
    .item {
      width: 100px; /* 固定宽度 */
      height: 100px; /* 固定高度 */
      background-color: #42b983;
      display: flex;
      justify-content: center;
      align-items: center;
      color: white;
      font-family: Arial, sans-serif;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
    <div class="item">4</div>
    <div class="item">5</div>
    <div class="item">6</div>
    <div class="item">7</div>
    <div class="item">8</div>
  </div>

  <script>
    // 动态切换 align-content 的值
    const container = document.querySelector('.container');
    const alignContentValues = [
      'flex-start',
      'flex-end',
      'center',
      'space-between',
      'space-around',
      'stretch'
    ];
    let currentIndex = 0;

    // 每隔 2 秒切换 align-content 的值
    setInterval(() => {
      container.style.alignContent = alignContentValues[currentIndex];
      currentIndex = (currentIndex + 1) % alignContentValues.length;
    }, 2000);
  </script>
</body>
</html>